package com.digitalchina.lxnsy.viewholder;

import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.ConsultDynamicListVO;
import com.digitalchina.lxnsy.toolkit.StringUtil;
import com.digitalchina.lxnsy.toolkit.TimeUtil;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

import java.text.ParseException;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：郑皓
 * 创建时间：2018/2/7 11:45:58
 * 修改备注：
 * ================================================
 */

public class ConsultDynamicListHolder extends BaseViewHolder<ConsultDynamicListVO> {


    private TextView tvTel;
    private TextView tvTime;
    private TextView tvIssue;
    private TextView tvReplyNum;
    private TextView tvCommentNum;

    public ConsultDynamicListHolder(ViewGroup parent) {
        super(parent, R.layout.item_consult_dynamic_list);

        tvTel = $(R.id.tv_tel);
        tvTime = $(R.id.tv_time);
        tvIssue = $(R.id.tv_issue);
        tvReplyNum = $(R.id.tv_reply_num);
        tvCommentNum = $(R.id.tv_comment_num);
    }

    @Override
    public void setData(final ConsultDynamicListVO data) {
        super.setData(data);

      //  tvTel.setText(data.getUserInfo().mobilePhone.replaceAll("(\\d{3})\\d{7}(\\d{1})", "$1*******$2"));


     //   tvTel.setText(data.getQuestionInfoModel()!=null&&data.getQuestionInfoModel().getUserInfo()!=null&&data.getQuestionInfoModel().getUserInfo().mobilePhone!=null ? data.getQuestionInfoModel().getUserInfo().mobilePhone.replaceAll("(\\d{3})\\d{7}(\\d{1})", "$1*******$2") : "匿名用户");
        try {
            tvTime.setText(data.getCreateTime() != null?TimeUtil.getDatebefore2(data.getCreateTime()):"");
        } catch (ParseException e) {
            e.printStackTrace();
        }

        tvIssue.setText( data.getContent());
        tvReplyNum.setText(data.getReplyQuantity()+"个回复");
        //tvCommentNum.setText(data.getCommentNum() + "个评论");
    }

}
